<?php
class gExtra {
	public static function ajaxTableOp($table_name, $A, $data='') {
		is_array($data) or $data = $_GET;
    	switch($data['ac']) {
    		case 'get':
    			$page = intval($data['page']);
    			$pp = intval($data['pp']);
    			$page = max(1, $page);
    			$pp = max(10, $pp);
    			
    			$start = ($page-1)*$pp;
    			$A->ajaxReturn(M($table_name)->where(array('uid'=>$_ENV['g']->uid))->limit($start, $pp)->select());
    			break;
    		default:
	    		$A->ajaxReturn('',L('bad_submit'),-1);
    			break;
    	}
	}
}